const express = require('express')
const morgan = require('morgan')
const app = express()
const toursRouter = require('./routes/tourRouter')
const userRouter = require('./routes/userRouter')

// 使用express 自带的中间件
app.use(express.json())
if (process.env.NODE_ENV === 'development') {
  app.use(morgan('dev'))
}

// 设置静态文件路径
app.use(express.static(`${__dirname}/public`))

app.use('/api/v1/tours', toursRouter)
app.use('/api/v1/users', userRouter)

module.exports = app
